package com.example.quart.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.pojo.vo.common.Result;
import com.example.quart.pojo.vo.QuartzJobVo;
import com.example.quart.service.QuartzService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LiYuhang
 * @version 0.1
 * @application
 * @Date 2020/11/1 16:35
 */
@RestController
@RequestMapping(value = "quartz")
@Slf4j
public class QuartzController {

    @Autowired
    private QuartzService quartzJobService;

    @RequestMapping(value = "")
    public Result search() {
        log.info("okok");
        return Result.OK();
    }

    @RequestMapping("/updateJob")
    @ResponseBody
    public Result updateJob(QuartzJobVo quartzJobVo) {
        try {
            quartzJobService.updateJob(quartzJobVo);
            return Result.OK();
        } catch (Exception e) {
            log.error("updateJob  error {}",e.getMessage(),e);
            return Result.error(e.getMessage());
        }
    }

}
